package pers.course.week3;

import java.util.Scanner;

public class Reverse {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int nums = in.nextInt();
        for(int i = 0; i < nums; i++)
        {
            int number = in.nextInt();
            if(number < 0)
            {
                number = Math.abs(number);
                System.out.print("-");
            }
            //去掉尾数上所有的0
            while(number % 10 == 0) {
                number /= 10;
            }
            //倒序逐位打印数字
            while(number>=1)
            {
                System.out.print(number % 10);
                number /= 10;
            }
            System.out.print("\n");
        }
        in.close();
    }
}
